package com.pureut.storage.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.storage.dto.MaterialFreezingDto;
import com.pureut.storage.dto.WmsStockInfoDto;
import com.pureut.storage.service.MaterialFreezingService;
import com.pureut.storage.vo.MaterialFreezingVo;
import com.pureut.storage.vo.WmsStockInfoVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: CM
 * @date: 2023/1/6  17:31
 */
@RestController
@RequestMapping("/materialFreezing")
public class MaterialFreezingController extends BaseController {

    @Resource
    private MaterialFreezingService materialFreezingService;

    /**
     *  生产冻结列表查询
     */
    @GetMapping("/list")
    public TableDataInfo getList(MaterialFreezingVo materialFreezingVo) {
        startPage();
        //查询库存列表
        List<MaterialFreezingDto> list = materialFreezingService.getList(materialFreezingVo);
        return getDataTable(list);
    }

    /**
     *  生产冻结新增查询仓库列表
     */
    @GetMapping("/getStockInfoList")
    public TableDataInfo getStockInfoList(WmsStockInfoVo wmsStockInfoVo) {
        startPage();
        //查询库存列表
        List<WmsStockInfoDto> list = materialFreezingService.getStockInfoList(wmsStockInfoVo);
        return getDataTable(list);
    }

    /**
     * 新增生产冻结单
     */
     @RequiresPermissions("warehouse:inside:materialFreezing:frozen")
    @Log(title = "新增生产冻结单", businessType = BusinessType.INSERT)
    @PostMapping("/addFreezing")
    public AjaxResult addPickingComplete(@RequestBody MaterialFreezingVo materialFreezingVo) throws Exception {
        return toAjax(materialFreezingService.addPickingComplete(materialFreezingVo));
    }

    /**
     * 解冻
     */
    @RequiresPermissions("warehouse:inside:materialFreezing:thaw")
    @Log(title = "解冻", businessType = BusinessType.UPDATE)
    @PostMapping("/updateFreezing")
    public AjaxResult updateFreezing(@RequestBody MaterialFreezingVo materialFreezingVo) throws Exception {
        return toAjax(materialFreezingService.updateFreezing(materialFreezingVo));
    }

    /**
     * 等级判定
     */
     @RequiresPermissions("warehouse:inside:materialFreezing:treatment")
    @Log(title = "品质处理", businessType = BusinessType.UPDATE)
    @PostMapping("/updateGradeFreezing")
    public AjaxResult updateGradeFreezing(@RequestBody MaterialFreezingVo materialFreezingVo) throws Exception {
        return toAjax(materialFreezingService.updateGradeFreezing(materialFreezingVo));
    }

    /**
     * 回显单据
     */
    @GetMapping("/view/{ids}")
    public TableDataInfo view(@PathVariable("ids") String ids) throws Exception {
        startPage();
        //查询库存列表
        List<MaterialFreezingDto> list = materialFreezingService.view(ids);
        return getDataTable(list);
    }



}
